package com.sqx.modules.errand.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.sqx.modules.errand.entity.*;
import com.sqx.modules.errand.vo.IndentVo;
import com.sqx.modules.errand.vo.RiderVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;

@Mapper
public  interface IndentDao extends BaseMapper<Indent> {

    Indent selectIndentByIndentNumber(@Param("indentNumber") String indentNumber);

    IPage<Indent> findNewIndent(@Param("iPage") Page<Indent> iPage, @Param("lng") Double lng, @Param("lat") Double lat, @Param("range") String range, @Param("indent") Indent indent);


    int indentReceiving(@Param("riderUserId") Long userId, @Param("indentNumber") String indentNumber, @Param("receivingTime") String receivingTime);

    IndentVo indentMessage(@Param("indentNumber") String indentNumber);


    List<Indent> findNoPay(@Param("createTime") String before5);

    int cancelIndent(@Param("indentNumber") String indentNumber);

    //修改账户余额
    int updateRiderBalance(@Param("balance") BigDecimal balance, @Param("userId") Long userId);
    //修改账户保证金
    int updateRiderCashDeposit(@Param("cashDeposit") BigDecimal cashDeposit, @Param("userId") Long userId);




    SysComplaint findComplaint(@Param("userId") Long userId, @Param("complaintId") Long complaintId, @Param("indentNumber")String indentNumber);


    int addComplaint(@Param("riderUserId") Long riderUserId, @Param("indentNumber") String indentNumber, @Param("complaintType") String complaintType,
                     @Param("wrongExplain") String wrongExplain, @Param("resultHanding") String resultHanding, @Param("complaintTime") Timestamp complaintTime,
                     @Param("shipAddressDetail") String shipAddressDetail, @Param("deilveryAddressDetail") String deilveryAddressDetail,
                     @Param("indentType") String indentType, @Param("deductMoney") BigDecimal deductMoney);

    int userDelivery(@Param("userId") Long userId, @Param("indentNumber") String indentNumber, @Param("finishTime")String date);


    int userEvaluate(@Param("userId") Long userId, @Param("riderUserId")Long riderUserId,@Param("indentNumber") String indentNumber,@Param("evaluateMessage") String evaluateMessage, @Param("satisfactionFlag")String satisfactionFlag, @Param("createTime") String date);

    List<RiderVo> findVicinityRider(@Param("lng") double lng, @Param("lat") double lat, @Param("distance") String distance);

    Indent findIndentByNumber(@Param("indentNumber") String indentNumber);


    int insertUserMoneyDetails(@Param("userId")Long userId,@Param("title") String title, @Param("type")Integer type, @Param("money")BigDecimal money, @Param("content")String content, @Param("createTime")String createTime);


    List<Indent> selectIndentList(Long userId);

    void indentReceiv(Long userId, String indentNumber, String format);

    List<Indent> selectSendOrder(String date);


    IPage<Indent> getIndentList(@Param("pages") Page<Indent> pages, @Param("userId") Long userId, @Param("indentType") Integer indentType, @Param("indentNumber") String indentNumber, @Param("startTime") String startTime, @Param("endTime") String endTime);

    BigDecimal getOneProfit(@Param("userId") Long userId, @Param("level") int level);

    IPage<HashMap<String, Object>> getProfitList(@Param("pages") Page<HashMap<String, Object>> pages, @Param("time") String time, @Param("flag") Integer flag);

    Integer getNowBeforeCount(@Param("riderId") Long riderId, @Param("finishTime") LocalDateTime finishTime);

    IPage<Indent> getRiderIndentList(@Param("pages") Page<Indent> pages, @Param("userId") Long userId, @Param("indentState") String indentState);

    List<IndentVo> indentExcelOut(@Param("indentType") String indentType, @Param("indentNumber") String indentNumber, @Param("indentState") String indentState, @Param("phone") String phone, @Param("date") String date, @Param("dateType") String dateType, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("parentName") String parentName, @Param("parentParentName") String parentParentName);

    int getUserIndentCount(@Param("userId") Long userId);

    BigDecimal getUserIndentMoney(@Param("userId") Long userId);

    BigDecimal agentStatistics(@Param("date") String date, @Param("dateType") String dateType, @Param("indentType") Integer indentType, @Param("cityId") Long cityId);
}



